package club.hicode.daydayup.xml;

import cn.hutool.core.util.XmlUtil;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

import java.io.File;
import java.util.List;

/**
 * 对XML进行测试
 *
 * @author Liu Chunfu
 * @date 2018-07-02 下午12:32
 **/
public class XmlTest {

    @Test
    public void test1() {
        Document document = XmlUtil.readXML(new File("/Users/liuchunfu/Desktop/ServerStatu.xml"));

        Element rootElement = XmlUtil.getRootElement(document);
        List<Element> server = XmlUtil.getElements(rootElement, "Server");
        for (Element element : server) {
            System.out.println(element.getAttribute("ServerName"));
        }

    }
}
